package com.g2room.driving.grap.life;

import java.io.IOException;
import java.net.MalformedURLException;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;

import org.jsoup.nodes.Document;
import org.jsoup.nodes.Element;
import org.jsoup.select.Elements;

import com.alibaba.fastjson.JSON;
import com.g2room.driving.grap.GenericGrap;
import com.g2room.driving.util.ImageUtil;
import com.g2room.myuall.grap.ky.model.po.GrapErr;
import com.g2room.myuall.grap.univ.po.Article;
import com.g2room.myuall.util.DbUtil;
import com.g2room.myuall.util.HtmlUtil;
import com.g2room.myuall.util.StringUtil;
import com.gargoylesoftware.htmlunit.FailingHttpStatusCodeException;

public class GrapChangshiData implements Runnable {
	//http://www.cwbol.com/
//	public String baseUrl = "http://www.cwbol.com";
//	private String source = "全民养生网";
//	public String baseUrl = "http://www.360changshi.com/";
//	private String source = "360常识网";
	public String baseUrl = "http://www.zuilxy.com/";
	private String source = "流行语";
	private static List<Article> artiss = new ArrayList<Article>();

	private Article artis;
	public static void main(String[] args) throws Exception{
		GrapChangshiData.getSourceUrl();
		// 获取360常识网的方法
 		GrapChangshiData gcd = new GrapChangshiData();
// 		gcd.getLiuxingyuNav();
// 		gcd.getZhiChangNav();
 		
// 		System.out.println("===小类数量：" + artiss.size());
// 		for(Article a : artiss) {
// 			gcd.get360ChangshiPage(a.getSourceUrl());
// 		}
 		
// 		System.out.println("===小类数量：" + artiss.size());
// 		for(Article a : artiss) {
// 			GrapChangshiData gl = new GrapChangshiData();
//        	gl.artis = a;
//        	Thread t = new Thread(gl);
//        	t.start();
//        }
 		
 		GrapChangshiData gl = new GrapChangshiData();
 		for(Article a : artiss) {
 			System.out.println(a.getSourceUrl());
 			if(a.getHot().equals("2")) {
 				gl.get360ChangshiPage(a.getSourceUrl(), a.getState());
 			} else if(a.getHot().equals("3")) {
 				gl.get360CahngshiList(a.getSourceUrl(), a.getState());
 			} else if(a.getHot().equals("4")) {
 				gl.get360ChangshiDetail(a);
 			}
        }
	}
	
	public Document getDoc(String url, String errCode) {
		// 获取分页信息
		Document doc = null;
		try {
			doc = GenericGrap.getDocByIp(url);
		} catch (IOException e) {
			e.printStackTrace();
			System.out.println(url + "======" + e.getMessage());
			GrapErr ge = new  GrapErr();
			ge.setUrl(url);
			ge.setType(errCode);
			ge.setDescription("错误："+e.getMessage());
			insert2ErrDb(ge);
		}
		return doc;
	}

	

	public void getZhiChangNav() {
		Document doc = getDoc("http://www.zcbkw.com/", "21");
		if(null == doc) return;
		
		Elements els = null;
		List<String> purls = new ArrayList<String>();
		els = doc.select(".newnav_main a");
		for(Element el : els) {
			if(el.attr("href").split("/").length == 3 && !el.attr("href").startsWith("http")) {
				purls.add(el.attr("href"));
			}
		}
		// 更多的
		els = doc.select("#more2");
		for(Element el : els) {
			if(!el.attr("href").startsWith("http")) {
				purls.add(el.attr("href"));
			}
		}
		System.out.println("===职场数量：" + artiss.size());
 		for(Article a : artiss) {
 			getZhiChangPage(a.getSourceUrl(), 1);
 		}
	}

	/**
	 * 获取分页列表
	 * @param url
	 * @throws FailingHttpStatusCodeException
	 * @throws MalformedURLException
	 * @throws IOException
	 */
	public void getZhiChangPage(String url, int state) {
		// 获取分页信息
		Document doc = getDoc(url, "22");
		if(doc == null) return;
		List<String> listUrls = new ArrayList<String>();
		Elements els = doc.select(".epages a");
		listUrls.add(url);
		if(null != els && !els.isEmpty()) {
			String text = els.get(els.size() - 1).attr("href");
			try {
				// /zcgl/faze/index_5.html
				// http://www.zcbkw.com/zcgl/faze/ index_2.html
				Integer i = Integer.parseInt(text.substring(text.lastIndexOf("/")+1));
				for(int j = 2; j<i+1; j++) {
					listUrls.add(url + "/index_"+j+".html");
				}
			} catch (Exception e) {
				e.printStackTrace();
			}
		}
		
        for(String listUrl : listUrls) {
        	getZhiChangList(listUrl, state);
        }
	}
	
	/**
	 * 获取列表列表
	 */
	public void getZhiChangList(String url, int state) {
		// 获取分页信息
		Document doc = getDoc(url, "23");
		if(doc == null) return;
		Elements els = doc.select(".left2 ul li a");
		List<String> durls = new ArrayList<String>();
		if(null != els && !els.isEmpty()) {
			for(Element el : els) {
				durls.add("http://www.zcbkw.com"+el.attr("href"));
			}
		}

		List<Article> artiss = new ArrayList<Article>();
        for(String durl : durls) {
        	Article ar = getZhiChangDetail(durl);
        	if(null != ar) artiss.add(ar);
        }
        if(artiss.size() > 0) insertArtiDb(artiss);
	}
	
	/**
	 * 获取列表列表
	 */
	public Article getZhiChangDetail(String url) {
		// 获取分页信息
		Document doc = getDoc(url, "24");
		if(doc == null) return null;
		Article arti = new Article();
		Elements els = doc.select(".content1_L a");
		// 获取类别
		if(null != els && !els.isEmpty()) {
			arti.setCategoryName("职场");
			arti.setTypeName(els.get(1).text());
			arti.setClassName(els.get(2).text());
		}
		arti.setSourceUrl(url);
		els = doc.select(".content2 .left h1");
		if(null != els && !els.isEmpty()) {
			arti.setTitle(els.first().text());
		}
		els = doc.select(".content2 .left .lei .lei_L span");
		if(null != els && !els.isEmpty()) {
			// 发布：2017-02-21
			arti.setPublishTime(els.get(1).text());
		}
		els = doc.select("#news_main");
		if(null != els && !els.isEmpty()) {
			arti.setContent(HtmlUtil.delAllTag(els.first().html()));
			String t = els.first().text().trim();
			arti.setSummary(t.substring(0, Math.min(150, t.length())));
			// 判断是否有图片，有则获取第一张图片作为封面
			els = els.first().getElementsByTag("img");
			if(null != els && !els.isEmpty()) {
				String src = els.first().attr("src");
				if(src.startsWith("http:")) {
					arti.setCover(src);
					// 获取宽度高度
					Map<Integer, Integer> map = ImageUtil.getImgWidth(arti.getCover());
					if(null != map) {
						for(int key : map.keySet()) {
							arti.setCoverWidth(key);
							arti.setCoverHeight(map.get(key));
						}
					}
				}
			}
		}
		return arti;
	}
	boolean f = false;
	public void getLiuxingyuNav() {
		Document doc = getDoc(baseUrl, "11");
		if(null == doc) return;
		
		Elements els =doc.select(".nav li a");
		for(int i = 0; i < els.size(); i++) {
			String catName = "";
			catName = els.get(i).text();
			if(catName.equals("首页")) continue;
//			if(catName.equals("娱乐八卦")) f = true;
			if(catName.equals("语录段子")) f = true;
			if(f) {
			Article arti = new Article();
			arti.setSourceUrl(els.get(i).attr("href"));
			arti.setCategoryName(catName);
			artiss.add(arti);
			}
		}
		System.out.println("===小类数量：" + artiss.size());
 		for(Article a : artiss) {
 			getLiuxingyuPage(a.getSourceUrl(), 1);
 		}
	}

	/**
	 * 获取分页列表
	 * @param url
	 * @throws FailingHttpStatusCodeException
	 * @throws MalformedURLException
	 * @throws IOException
	 */
	public void getLiuxingyuPage(String url, int state) {
		// 获取分页信息
		Document doc = getDoc(url, "12");
		if(doc == null) return;
		List<String> listUrls = new ArrayList<String>();
		Elements els = doc.select(".pagination li a");
		listUrls.add(url);
		if(null != els && !els.isEmpty()) {
			String text = els.get(els.size() - 1).attr("href");
			try {
				// http://www.zuilxy.com/liuxing/page/30
				Integer i = Integer.parseInt(text.substring(text.lastIndexOf("/")+1));
				for(int j = 2; j<i+1; j++) {
					listUrls.add(url + "/page/"+j);
				}
			} catch (Exception e) {
				e.printStackTrace();
			}
		}
		
        for(String listUrl : listUrls) {
        	getLiuxingyuList(listUrl, state);
        }
	}
	
	/**
	 * 获取列表列表
	 */
	public void getLiuxingyuList(String url, int state) {
		// 获取分页信息
		Document doc = getDoc(url, "13");
		if(doc == null) return;
		Elements els = doc.select(".content article header h2 a");
		List<String> durls = new ArrayList<String>();
		if(null != els && !els.isEmpty()) {
			for(Element el : els) {
				durls.add(el.attr("href"));
			}
		}

		List<Article> artiss = new ArrayList<Article>();
        for(String durl : durls) {
        	Article ar = getLiuxingyuDetail(durl);
        	if(null != ar) artiss.add(ar);
        }
        if(artiss.size() > 0) insertArtiDb(artiss);
	}
	
	/**
	 * 获取列表列表
	 */
	public Article getLiuxingyuDetail(String url) {
		// 获取分页信息
		Document doc = getDoc(url, "14");
		if(doc == null) return null;
		Article arti = new Article();
		Elements els = doc.select(".breadcrumbs a");
		// 获取类别
		if(null != els && !els.isEmpty()) {
			arti.setCategoryName("流行语");
			arti.setTypeName(els.get(1).text());
		}
		arti.setSourceUrl(url);
		els = doc.select(".article-title");
		if(null != els && !els.isEmpty()) {
			arti.setTitle(els.first().text());
		}
		els = doc.select(".article-meta li");
		if(null != els && !els.isEmpty()) {
			// 发布：2017-02-21
			arti.setPublishTime(els.first().text().replace("发布：", ""));
		}
		els = doc.select(".article-content");
		if(null != els && !els.isEmpty()) {
			arti.setContent(HtmlUtil.delAllTag(els.first().html()).replaceAll("流行语大全网", "<a href=\"http://www.1nsh.com\">一念生活网</a>"));
			arti.setSummary(els.first().text().trim().replaceAll("流行语大全网", "一念生活网"));
			// 判断是否有图片，有则获取第一张图片作为封面
			els = els.first().getElementsByTag("img");
			if(null != els && !els.isEmpty()) {
				String src = els.first().attr("src");
				if(src.startsWith("http:")) {
					arti.setCover(src);
					// 获取宽度高度
					Map<Integer, Integer> map = ImageUtil.getImgWidth(arti.getCover());
					if(null != map) {
						for(int key : map.keySet()) {
							arti.setCoverWidth(key);
							arti.setCoverHeight(map.get(key));
						}
					}
				}
			}
		}
		return arti;
	}
	
	public void get360ChangshiNav() {
		Document doc = getDoc(baseUrl, "1");
		if(null == doc) return;
		
		Elements els =doc.select(".nav_list a");
		Elements ulels = doc.select(".leveltwo-list-content ul");
		for(int i = 0; i < els.size(); i++) {
			String catName = "";
			catName = els.get(i).text();
			if(catName.equals("首页")) continue;
			Elements aels = ulels.get(i -1).select("li a");
			if(null != aels && !aels.isEmpty()) {
				for(Element el : aels) {
					Article arti = new Article();
					arti.setSourceUrl(el.attr("href"));
					arti.setCategoryName(catName);
					arti.setTypeName(el.text());
					artiss.add(arti);
				}
			}
		}
	}

	/**
	 * 获取分页列表
	 * @param url
	 * @throws FailingHttpStatusCodeException
	 * @throws MalformedURLException
	 * @throws IOException
	 */
	public void get360ChangshiPage(String url, int state) {
		// 获取分页信息
		Document doc = getDoc(url, "2");
		if(doc == null) return;
		List<String> listUrls = new ArrayList<String>();
		Elements els = doc.select(".paging span a");
		listUrls.add(url);
		if(null != els && !els.isEmpty()) {
			String text = els.get(els.size() - 2).text();
			try {
				// ./list_99.html
				Integer i = Integer.parseInt(text);
				for(int j = 2; j<i+1; j++) {
					listUrls.add(url + "list_"+j+".html");
				}
			} catch (Exception e) {
				e.printStackTrace();
			}
		}
		
        for(String listUrl : listUrls) {
        	sleep();
        	get360CahngshiList(listUrl, state);
        }
	}
	
	/**
	 * 获取列表列表
	 */
	public void get360CahngshiList(String url, int state) {
		// 获取分页信息
		Document doc = getDoc(url, "3");
		if(doc == null) return;
		Elements els = doc.select(".tags_list div.list");
		List<Article> artis = new ArrayList<Article>();
		if(null != els && !els.isEmpty()) {
			for(Element el : els) {
	 			Article arti = new Article();
	 			arti.setState(state);
	 			Elements tels = el.select(".title h3 a");
	 			if(null != tels && !tels.isEmpty()) {
	 				arti.setTitle(tels.first().text());
	 				arti.setSourceUrl(tels.first().attr("href"));
	 			}
	 			// 获取摘要
	 			tels = el.select("p");
	 			if(null != tels && !tels.isEmpty()) {
	 				arti.setSummary(tels.first().text());
	 			}
				arti.setSource(source);
				artis.add(arti);
			}
		}

//		List<Article> artiss = new ArrayList<Article>();
        for(Article arti : artis) {
        	sleep();
        	Article ar = get360ChangshiDetail(arti);
//        	if(null != ar) artiss.add(ar);
        }
//        if(artiss.size() > 0) insertArtiDb(artiss);
	}
	public void sleep() {
    	try {
    		Thread.sleep(Integer.parseInt(StringUtil.genRandomNum(1)) * 100);
    	} catch (Exception e) {
    	}
	}
	
	/**
	 * 获取列表列表
	 */
	public Article get360ChangshiDetail(Article arti) {
		// 获取分页信息
		Document doc = getDoc(arti.getSourceUrl(), "4");
		if(doc == null) return null;
		Elements els = doc.select(".main .article .xinxi");
		if(null != els && !els.isEmpty()) {
			// 2016-03-18 09:08:34　　来源：360常识网　       	        	 　热度：
			String text = els.first().text();
			if(StringUtil.isNotBlank(text)) {
				arti.setPublishTime(text.trim().split("　　")[0]);
			}
		}
		arti.setSourceUrl(arti.getSourceUrl());
//		if(StringUtil.isBlank(arti.getTitle())) {
		els = doc.select(".main .article h1");
		if(null != els && !els.isEmpty()) {
			arti.setTitle(els.first().text());
		}
//		}
//		if(StringUtil.isBlank(arti.getSummary())) {
		els = doc.select(".article .summary");
		if(null != els && !els.isEmpty()) {
			els.select("span").remove();
			arti.setSummary(els.first().text());
		}
//		}
		els = doc.select(".desc");
		if(null != els && !els.isEmpty()) {
			els = els.first().children();
			StringBuffer content = new StringBuffer();
			for(Element el : els) {
				if(el.tagName().equalsIgnoreCase("div") && el.id().equals("rw")) {
					break;
				}
				content.append(el.outerHtml());
			}
			
			arti.setContent(HtmlUtil.delAllTag(content.toString()));
			// 判断是否有图片，有则获取第一张图片作为封面
			els = els.first().getElementsByTag("img");
			if(null != els && !els.isEmpty()) {
				String src = els.first().attr("src");
				if(src.startsWith("http:")) {
					arti.setCover(src);
				}
				// 获取宽度高度
				Map<Integer, Integer> map = ImageUtil.getImgWidth(arti.getCover());
				if(null != map) {
					for(int key : map.keySet()) {
						arti.setCoverWidth(key);
						arti.setCoverHeight(map.get(key));
					}
				}
			}
		}
		// 分类
		els = doc.select(".weizhi .left a");
		if(null != els && !els.isEmpty()) {
			arti.setCategoryName(els.get(1).text());
			arti.setTypeName(els.get(2).text());
		}
		insertArtiDb(arti);
		return arti;
	}
	
	public void getCwbolNav() {
		Document doc = getDoc(baseUrl, "1");
		if(null == doc) return;
		
		Elements els =doc.select(".subnav .box1");
		for(Element el : els) {
			Elements tels = el.select("h2 a");
			String catName = "";
			if(null != tels && !tels.isEmpty()) {
				catName = tels.first().text();
			}
			
			tels = el.select("ul li a");
			if(null != tels && !tels.isEmpty()) {
				for(Element tel : tels) {
					Article arti = new Article();
					arti.setSourceUrl(tel.attr("href"));
					arti.setCategoryName("养生");
					arti.setTypeName(catName);
					arti.setClassName(tel.text());
					artiss.add(arti);
				}
			}
		}
	}
	
	/**
	 * 获取分页列表
	 * @param url
	 * @throws FailingHttpStatusCodeException
	 * @throws MalformedURLException
	 * @throws IOException
	 */
	public void getPage(Article arti) {
		// 获取分页信息
		Document doc = getDoc(arti.getSourceUrl(), "2");
		if(doc == null) return;
		List<String> listUrls = new ArrayList<String>();
		Elements els = doc.select(".apaging ul span a");
		listUrls.add(arti.getSourceUrl());
		if(null != els && !els.isEmpty()) {
			String text = els.get(els.size() - 1).attr("href");
			try {
				// ./list_99.html
				Integer i = Integer.parseInt(text.substring(text.indexOf("_")+1, text.lastIndexOf(".")));
				for(int j = 1; j<i+2; j++) {
					// http://www.cwbol.com/ysys/yyys/list_1.html
					listUrls.add(arti.getSourceUrl() + "list_" + j + ".html");
				}
			} catch (Exception e) {
				e.printStackTrace();
			}
		}
		
        for(String listUrl : listUrls) {
        	getList(listUrl, arti);
        }
	}
	
	/**
	 * 获取列表列表
	 */
	public void getList(String url, Article art) {
		// 获取分页信息
		Document doc = getDoc(url, "3");
		if(doc == null) return;
		Elements els = doc.select(".con_left .news");
		List<Article> artis = new ArrayList<Article>();
		if(null != els && !els.isEmpty()) {
			for(Element el : els) {
	 			Article arti = new Article();
	 			Elements tels = el.select("a img");
	 			if(null != tels && !tels.isEmpty()) {
	 				arti.setCover(tels.first().attr("src"));
	 				// 获取宽度高度
	 				Map<Integer, Integer> map = ImageUtil.getImgWidth(tels.first().attr("src"));
	 				if(null != map) {
	 					for(int key : map.keySet()) {
	 						arti.setCoverWidth(key);
	 						arti.setCoverHeight(map.get(key));
	 					}
	 				}
	 			}
	 			// 获取链接和title
	 			tels = el.select(".news_title h4 a");
	 			if(null != tels && !tels.isEmpty()) {
	 				arti.setTitle(tels.first().text());
	 				arti.setSourceUrl(tels.first().attr("href"));
	 			}
	 			// 获取链接和title
	 			tels = el.select(".news_span1");
	 			if(null != tels && !tels.isEmpty()) {
	 				arti.setPublishTime(tels.first().text());
	 			}
	 			arti.setCategoryName(art.getCategoryName());
	 			arti.setTypeName(art.getTypeName());
				arti.setClassName(art.getClassName());
				arti.setState(art.getState());
				arti.setSource(source);
				artis.add(arti);
			}
		}

		List<Article> artiss = new ArrayList<Article>();
        for(Article arti : artis) {
        	Article ar = getDetail(arti);
        	if(null != ar) artiss.add(ar);
        }
        if(artiss.size() > 0) insertArtiDb(artiss);
	}
	
	/**
	 * 获取列表列表
	 */
	public Article getDetail(Article arti) {
		// 获取分页信息
		Document doc = getDoc(arti.getSourceUrl(), "4");
		if(doc == null) return null;
		Elements els = doc.select(".content_text");
		if(null != els && !els.isEmpty()) {
			els = els.first().children();
			StringBuffer content = new StringBuffer();
			int start = 0;
			for(Element el : els) {
				if(el.tagName().equalsIgnoreCase("p")) {
					start++;
				}
				if(start > 2 && el.tagName().equalsIgnoreCase("script")) {
					start = 0;
				}
				
				if(start > 0) {
					content.append(el.outerHtml());
				}
			}
			
			arti.setContent(HtmlUtil.delAllTag(content.toString()));
			if(StringUtil.isBlank(arti.getCover())) {
				// 判断是否有图片，有则获取第一张图片作为封面
				els = els.first().getElementsByTag("img");
				if(null != els && !els.isEmpty()) {
					String src = els.first().attr("src");
					if(src.startsWith("http:")) {
						arti.setCover(src);
					}
					// 获取宽度高度
					Map<Integer, Integer> map = ImageUtil.getImgWidth(arti.getCover());
					if(null != map) {
						for(int key : map.keySet()) {
							arti.setCoverWidth(key);
							arti.setCoverHeight(map.get(key));
						}
					}
				}
			}
		}
		
		els = doc.select(".location a");
		if(null != els && !els.isEmpty()) {
			arti.setClassName(els.get(1).text());
			arti.setTitle(els.get(2).text());
		}
		els = doc.select(".con_left_title .info span");
		if(null != els && !els.isEmpty()) {
			arti.setPublishTime(els.get(2).text().replaceAll("时间：", ""));
		}
		arti.setCategoryName("养生");
		insertArtiDb(arti);
		return arti;
	}
	

	public void insertArtiDb(Article arti) {
		List<Article> as = new ArrayList<Article>();
		as.add(arti);
		insertArtiDb(as);
	}
	public void insertArtiDb(List<Article> artis) {
		String sql = "insert into life_knowledge(category_name,type_name,content,source_url,class_name,source,title,publish_time,cover,cover_height,cover_width, state,summary) values(?,?,?,?,?,?,?,?,?,?,?,?,?)";
		PreparedStatement ps = null;
		try {
			ps = DbUtil.getConn("life_grap").prepareStatement(sql);
			for(Article cc : artis) {
				ps.setString(1, cc.getCategoryName());
				ps.setString(2, cc.getTypeName());
				ps.setString(3, cc.getContent());
				ps.setString(4, cc.getSourceUrl());
				ps.setString(5, cc.getClassName());
				ps.setString(6, cc.getSource());
				ps.setString(7, cc.getTitle());
				ps.setString(8, cc.getPublishTime());
				ps.setInt(10, cc.getCoverHeight());
				ps.setInt(11, cc.getCoverWidth());
				ps.setString(9, cc.getCover());
				ps.setInt(12, cc.getState());
				ps.setString(13, cc.getSummary());
				ps.addBatch();
			}
			ps.executeBatch();	
		} catch (Exception e) {
			e.printStackTrace();
			GrapErr ge = new  GrapErr();
			ge.setType("5");
			ge.setContent(JSON.toJSONString(artis));
			ge.setDescription("获取DB错误");
			insert2ErrDb(ge);
		
		} finally {
			if(null != ps) {
				try {
					ps.close();
				} catch (SQLException e) {
					e.printStackTrace();
				}
			}
		}
	}

	public void insert2ErrDb(GrapErr ge) {
		PreparedStatement grapPs = null;
		try {
			grapPs = DbUtil.getConn("life_grap").prepareStatement("insert into grap_err(description,url,content,type) values(?,?,?,?)");
			grapPs.setString(1, ge.getDescription());
			grapPs.setString(2, ge.getUrl());
			grapPs.setString(3, ge.getContent());
			grapPs.setString(4, ge.getType());
			grapPs.execute();
			grapPs.close();
		} catch(Exception e) {
			e.printStackTrace();
		} finally {
			if(null != grapPs) {
				try {
					grapPs.close();
				} catch (SQLException e) {
					e.printStackTrace();
				}
			}
		}
	}

	@Override
	public void run() {
//		get360ChangshiPage(artis);
//		getPage(artis);
//        for(Article arti : artis) {
//        }
	}
	

	public static void getSourceUrl() {
		try {
			Connection connection = DbUtil.getConn("life_grap");
			Statement statement = connection.createStatement();
			String sql = "select url,id,type from grap_err where type < 10";
			ResultSet rs = statement.executeQuery(sql);
			while(rs.next()) {
				Article arti = new Article();
				arti.setSourceUrl(rs.getString("url"));
				arti.setState(rs.getInt("id"));
				arti.setHot(rs.getString("type"));
				artiss.add(arti);
			}
			rs.close();
			statement.close();
		} catch(Exception e) {
			e.printStackTrace();
		}
	}

}
